﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace MimosaV2Console
{
    class Program
    {
        private static ManualResetEvent m_proxyUp = new ManualResetEvent(false);

        [STAThread]
        static int Main(string[] args)
        {
            try
            {
                bool bNew;

                Mutex mutex = new Mutex(true, "mimosaV2", out bNew);
                if (bNew)
                {
                    Console.WriteLine("sipswitch starting");

                    StatefulDaemon daemon = new StatefulDaemon();

                    Thread daemonThread = new Thread(new ThreadStart(daemon.Start));
                    daemonThread.Start();

                    m_proxyUp.WaitOne();
                    return 2;
                }
                else
                {
                    return 0;
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception Main. " + excp.Message);
                return 0;
            }
        }
    }
}
